package com.pwt.model.crustallus;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.persistence.Transient;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @author dw
 * @version 1.0.0
 * @date 2021/10/12
 */
@Data
@Schema(name = "分组模型")
public class GroupModel {

    @Schema(description = "主键id")
    private Integer  id;

    @Schema(description = "名称")
    private  String name;

    @Schema(description = "订单编号")
    private  String orderId;

    @Schema(description = "生产单元数量")
    private Integer numberOfParts= 0;

    @Schema(description = "最大值")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date maxTime;

    @Schema(description = "最小值")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date minTime;

    @Schema(description = "数量值")
    private Integer count = 0;

    @Schema(description = "合格数量")
    private Integer qualified = 0;

    @Schema(description = "合格率")
    private BigDecimal qualifiedRate ;

    @Schema(description = "有合格的被测参数")
    private Integer hasQualified = 0;

    @Schema(description = "有合格的被测参数比率")
    private BigDecimal hasQualifiedRate;

    @Schema(description = "不合格数量")
    private Integer disqualification = 0 ;

    @Schema(description = "不合格率")
    private BigDecimal disqualificationRate;

    @Transient
    public void setGroupModel(GroupModel groupModel){
        this.id = groupModel.getId();
        this.name = groupModel.getName();
        this.numberOfParts = groupModel.getNumberOfParts();
        this.maxTime = groupModel.getMaxTime();
        this.minTime = groupModel.getMinTime();
        this.count = groupModel.getCount();
        this.qualified = groupModel.getQualified();
        this.qualifiedRate = groupModel.getQualifiedRate();
        this.hasQualified = groupModel.getHasQualified();
        this.hasQualifiedRate = groupModel.getHasQualifiedRate();
        this.disqualification = groupModel.getDisqualification();
        this.disqualificationRate = groupModel.getDisqualificationRate();
    }

}
